package p3.code;

import java.util.Arrays;


public class ReleaseObject {

    // 引用类型
    private String[] states = {"c","a","r"};

    /**
     * 不安全的对象发布
     */
    public String[] getStates(){
        return states;
    }

    public static void main(String[] args) {
        ReleaseObject test=new ReleaseObject();
        //外部可以得到Test的私有对象域且对它进行修改
        test.getStates()[0] = "b";
        System.out.println(Arrays.toString(test.getStates()));
    }

}
